package v1

import (
	"github.com/gin-gonic/gin"
	"zimuzu_cvn_web_api/config"
	"zimuzu_cvn_web_api/pkg/errno"
	"zimuzu_cvn_web_api/router/api"
	"zimuzu_cvn_web_api/router/api/web/middleware"
	"zimuzu_cvn_web_api/service"
)

type YqbAPI struct {
}

func (yqb YqbAPI) Name() string {
	return "yqb API"
}

func (yqb YqbAPI) Bind() {
	YqbAPI := config.C.Router.Group("/v1/yqb", middleware.TrackLog(), middleware.AuthMiddleware())
	{
		YqbAPI.GET("getWallet", getWallet)
	}
}

//获取充值地址
//Auth: TXG
func getWallet(c *gin.Context) {
	data := make(map[string]string)
	uid, _ := service.GetUserIdByRequest(c)
	wallet, err := service.GetWalletAddress(uid)
	if err != nil {
		api.SendResponse(c, errno.GetWalletERR, nil)
		return
	}
	data["wallet"] = wallet
	errno.OK.Info = "OK"
	api.SendResponse(c, errno.OK, data)
	return
}
